<!-- banner -->
<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
        *{
            margin: 0px;
            padding: 0px;
            list-style: none;
        }
        .pic{
            width: 520px;
            height: 280px;
            margin:100px auto;
            border-radius: 10px;
            position: relative;
            overflow: hidden;
        }
        ul{
            width: 9999px;
        }
        ul li{
            float: left;
            cursor: pointer;
        }
        
        ol{
            position: absolute;
            bottom: 10px;
            left: 50%;
            transform: translateX(-50%);
        }
        ol li{
            width: 10px;
            height: 10px;
            border-radius: 50%;
            background: white;
            float: left;
            margin: 0px 4px;
            cursor: pointer;
        }
        strong{
            position: absolute;
            top: 50%;
            transform: translateY(-50%);
            background: aqua;
            font-size: 30px;
            cursor: pointer;
            opacity:0.5;
        }
        strong:nth-of-type(1){
            left: 5px
        }
        strong:nth-of-type(2){
            right: 5px
        }
        .current{
            background: #f60;
        }
        </style>
    </head>
    <body>
        <div class="pic" id="wrap">
            <!-- 引入图片 -->
            <ul id="box">
                <li><img src="轮播图\images\pic.jpg" alt=""></li>
                <li><img src="轮播图\images\pic1.jpg" alt=""></li>
                <li><img src="轮播图\images\pic2.jpg" alt=""></li>
                <li><img src="轮播图\images\pic3.jpg" alt=""></li>
            </ul>
            <!-- ol>li一般引入有序的内容，实现小圆点 -->
            <ol id="list">
                <li class="current"></li>
                <li></li>
                <li></li>
                <li></li>
            </ol>
            <!-- 左右 -->
            <strong class="left" id="left"><</strong>
            <strong class="right" id="right">></strong>

            <script>
                var box=document.getElementById('box');
                var wrap=document.getElementById('wrap');
                var list=document.getElementById('list').children;
                var left=document.getElementById('left');
                var right=document.getElementById('right');
                var num=0;
                var timer; 
                function fn(){
                    timer=setInterval(function(){
                    num++;
                    if(num>3){
                        num=0;
                    }

                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-520*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                },2000)
                }

                fn()

                wrap.onmouseenter=function(){
                    clearInterval(timer)
                }
                wrap.onmouseleave=function(){
                   fn()
                }
                for(var i=0;i<list.length;i++){
                    list[i].index=i;
                    list[i].onclick=function(){
                        for(var j=0;j<list.length;j++){
                            list[j].className=''
                        }
                        this.className='current';
                        num=this.index;
                    n=-520*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                    }
                }
                right.onclick=function(){
                    num++;
                    if(num>3){
                        num=0;
                    }

                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-520*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                }
                left.onclick=function(){
                    num--;
                    if(num<0){
                        num=3;
                    }

                    for(var j=0;j<list.length;j++){
                            list[j].className='';
                        }
                    
                    list[num].className='current';
                    n=-520*num;
                    box.style.transform='translateX('+n+'px)'
                    box.style.transition='all 1s'
                }
            </script>
        </div>
    </body>
</html>